import qs from 'qs'

function s_get (key, obj = false) {
  obj ? qs.parse(sessionStorage.getItem(key)) : sessionStorage.getItem(key)
}

function s_set (key, value, obj = false) {
  obj ? sessionStorage.setItem(key, qs.stringify(value)) : sessionStorage.setItem(key, value)
}

function s_remove (key) {
  sessionStorage.removeItem(key)
}

function l_get (key, obj = false) {
  obj ? qs.parse(localStorage.getItem(key)) : localStorage.getItem(key)
}

function l_set (key, value, obj = false) {
  obj ? localStorage.setItem(key, qs.stringify(value)) : localStorage.setItem(key, value)
}

function l_remove (key) {
  localStorage.removeItem(key)
}

export default {
  s_get,
  s_set,
  s_remove,
  l_get,
  l_set,
  l_remove
}
